package com.example.demo.common;

import com.example.demo.entity.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author: cheng
 * @date: 2023/6/26 19:54
 * @description: 获取用户 uid 工具类
 */
public class UserSessionTools {
    public static UserInfo getLoginUser(HttpServletRequest request){
        HttpSession session = request.getSession(false);
        Object object = null;
        if (session != null && (object = session.getAttribute(ApplicationVariable.SESSION_KEY_USERINFO)) != null){
            return (UserInfo) object;
        }
        return null;
    }
}
